<template>
  <!--项目计划信息  -->
  <div>
    <FormPanel
      ref="formPanel"
      :list="initForm"
      :cols="1"
      formType="show"
      :labelWidth="120"
      :isSubmitBtn="false"
      @formChange="formChangeHandle"
    />
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      initForm: this.initFormFun(),
      formValue: {}
    };
  },
  mounted() {
    console.log(this.value); //获取到行id 、类型（新增、详情）
    //请求接口进行赋值，自己写吧
  },
  methods: {
    init() {
      if (this.value.type === 'edit') {
        this.initForm.forEach(x => {
          x.initialValue = this.value.row[x.fieldName];
        });
      }
    },
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'UPLOAD_FILE',
          label: '现场高清照片',
          disabled: this.type === 'show' ? true : false,
          fieldName: 'photoUrl',
          initialValue: '',
          upload: {
            actionUrl: '/api/file/oss/upload'
          }
        },
        {
          type: 'UPLOAD_FILE',
          label: '项目核销材料',
          disabled: this.type === 'show' ? true : false,
          fieldName: 'cancellationUrl',
          initialValue: '',
          upload: {
            actionUrl: '/api/file/oss/upload'
          }
        },
        {
          type: 'UPLOAD_FILE',
          label: '实际使用费用明细',
          disabled: this.type === 'show' ? true : false,
          fieldName: 'feeDetailUrl',
          initialValue: '',
          upload: {
            actionUrl: '/api/file/oss/upload'
          }
        },
        {
          type: 'UPLOAD_FILE',
          label: '合同报价单',
          disabled: this.type === 'show' ? true : false,
          fieldName: 'contractOfferUrl',
          initialValue: '',
          upload: {
            actionUrl: '/api/file/oss/upload'
          }
          // rules: [{ required: true, message: '请上传合同报价单', trigger: 'blur' }]
        },
        {
          type: 'UPLOAD_FILE',
          label: '发票',
          disabled: this.type === 'show' ? true : false,
          fieldName: 'billUrl',
          initialValue: '',
          upload: {
            actionUrl: '/api/file/oss/upload'
          }
          // rules: [{ required: true, message: '请上传发票', trigger: 'blur' }]
        },
        {
          type: 'UPLOAD_FILE',
          label: '其它',
          fieldName: 'otherUrl',
          initialValue: '',
          upload: {
            actionUrl: '/api/file/oss/upload',
            limit: 99
          }
        }
      ];
    },
    formChangeHandle(val) {
      this.formValue = val;
    }
  },
  created() {
    this.init();
  }
};
</script>
